/*
 * Copyright (c) 2001-2018 GuaHao.com Corporation Limited. All rights reserved.
 * This software is the confidential and proprietary information of GuaHao Company.
 * ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with GuaHao.com.
 */
package com.bgt.springboot.first.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

/**
 * TODO
 *
 * @author Ricky
 * @version V1.0
 * @since 2018-07-31 17:06
 */
public class Java8 {
    public static List<J8> datas=new ArrayList<>();
    public static void main(String[] args) {
        datas.add(new J8(1L));
        datas.add(new J8(2L));
        datas.add(new J8(3L));
        datas.add(new J8(4L));
      datas.forEach(s->{
          s.setId(1+s.getId());
      });
       datas.forEach(s->{
           System.out.println(s.getId());
       });
    }

    /**
     * List<J8>转为List<Long>类型
     * @param args
     */
    public static void main3(String[] args) {
        datas.add(new J8(1L));
        datas.add(new J8(2L));
        datas.add(new J8(3L));
        datas.add(new J8(4L));
        List<Long> results = datas.stream().map(result -> result.getId()).collect(Collectors.toList());
        System.out.println(results);
    }
}
class J8{
    private Long id;
    private String name;

    public J8(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
